• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 10:30am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 10:30am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Ea for take profit and stop movement based off risk(stop loss) 13 replies

Stop trading if xxx profit reach or lose 0 replies

Trading News before Releases XXX Strategy 16 replies

The XXX Alure Of The Trading Reality 30 replies

xXx system 191 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: How to stop trading for rest of the day if xxx profit reach
Cancel

How to stop trading for rest of the day if xxx profit reach

  • Post #1
  • Quote
  • First Post: Jul 13, 2019 3:57pm Jul 13, 2019 3:57pm
  •  deadlef
  • | Joined May 2017 | Status: Member | 12 Posts
can someone help how to to teach an ea when xxx amount of open orders reached than do not open trades for the rest of the day and start on next day.

I am counting my openorders right now like this.
Inserted Code
double Open_Orders_Profit()
{
   double openordersprofit = 0;
   RefreshRates();
   int Total=OrdersTotal();
   if(Total>0)
   {
      for(int i=Total-1; i>=0; i--)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==TRUE)
         {
            if(OrderSymbol()==Symbol() && OrderMagicNumber() == magicNumber)
            {
               openordersprofit +=OrderProfit()+OrderSwap()+OrderCommission();
            }
         }
      }
   }
   return(openordersprofit);
}

i have an input like this:

Inserted Code
input double TakeProfitInput = 100;

than i check this

Inserted Code
 if(Open_Orders_Profit()>=TakeProfitInput)    {           CloseAllPositions();      }

this is working well if ordersprofit > takeprofitinput ea is closing all trades.

i need now a function or code snippet that ea will not open any trades and beginn opening trades on next day.

someone any idea?

i thought about a bool tradeallowed and set it to false if CloseAllPositions function is called.but how can i code it to set it to true when next trading day begin..

or something like i put an input startnextday -->> so stop trading after closeall and start on startnextday input. someone an idea
  • Post #2
  • Quote
  • Edited 5:41pm Jul 14, 2019 3:21pm | Edited 5:41pm
  •  Beerrun
  • Joined Jan 2016 | Status: Good Coder | Bad Trader | 461 Posts
Quoting deadlef
Disliked
can someone help how to to teach an ea when xxx amount of open orders reached than do not open trades for the rest of the day and start on next day. I am counting my openorders right now like this. double Open_Orders_Profit() { double openordersprofit = 0; RefreshRates(); int Total=OrdersTotal(); if(Total>0) { for(int i=Total-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==TRUE) { if(OrderSymbol()==Symbol() && OrderMagicNumber() == magicNumber) { openordersprofit +=OrderProfit()+OrderSwap()+OrderCommission(); } } } } return(openordersprofit);...
Ignored
Try something like this, just make a new bar check and set it for the daily timeframe. When CloseAll() is called then the newbar is set, no bool variable needed. It won't allow the rest of the code to run until a new D1 bar opens.

Inserted Code
int start(){
  static datetime newday=0;
  if(newday>=iTime(NULL,1440,0))return(0);
  Open_Orders_Profit();
  //your trading logic here
  return(0);}
 
double Open_Orders_Profit(){
  double openordersprofit=0;
  for(int i=OrdersTotal()-1;i>=0;i--)
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==magicNumber)
     openordersprofit+=OrderProfit()+OrderSwap()+OrderCommission();
  if(openordersprofit>=TakeProfitInput){CloseAllPositions();newday=iTime(NULL,1440,0);}
  return(openordersprofit);}
 
 
  • Post #3
  • Quote
  • Last Post: Jul 17, 2019 11:12am Jul 17, 2019 11:12am
  •  deadlef
  • | Joined May 2017 | Status: Member | 12 Posts
how can i make a delay ..now it works fine..but i want also to say start at 9 oclock and not on directly new day cancle at night.
 
 
  • Platform Tech
  • /
  • How to stop trading for rest of the day if xxx profit reach
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023