Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnEachTick Enter or Exist on Trade.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    OnEachTick Enter or Exist on Trade.

    OnEachTick :
    - Purpose of the blow strategy is to enter in the Live Candle when it is forming ( Live Bar only) and Place the trade on the Green or Red candle.
    - Calculate = Calculate.OnEachTick;
    - it will exit the position when next forming candle will become Red or Green.

    Result :
    Unfortunately, it is working only once is it activated and nothing is happening after that.
    It is in Testing environment currently.

    Any suggestions, Please welcome and Thanks in advance.
    ================================================== ================================================== ====

    if( Close[0] > Open[0] ){

    if(IsFirstTickOfBar == true ){
    Print("Green" + Position.MarketPosition);
    if(Position.MarketPosition == MarketPosition.Short){
    ExitShort(1);
    Print("ExitShort " + Time[0] + " Current Open-->" + Open[0] + " Current Close " + Close[0]);
    }

    //SetStopLoss(CalculationMode.Ticks, 1);
    if(Position.MarketPosition != MarketPosition.Long){
    EnterLong(1, "GREEN "+ DateTime.Now );
    Print("Buy Signal " + Time[0] + " Current Open-->" + Open[0] + " Current Close " + Close[0]);
    }
    }
    }

    if( Close[0] < Open[0] ){

    if(IsFirstTickOfBar == true){
    Print("RED" + Position.MarketPosition);
    if(Position.MarketPosition == MarketPosition.Long){
    ExitLong(1);
    Print("ExitLong " + Time[0] + " Current Open-->" + Open[0] + " Current Close " + Close[0]);
    }

    //SetStopLoss(CalculationMode.Ticks, 1);
    if(Position.MarketPosition != MarketPosition.Short){
    EnterShort(1, "Short " + DateTime.Now);
    Print("RED Signal Entershort " + Time[0] + " Current Open-->" + Open[0] + " Current Close " + Close[0]);
    }

    }
    }

    #2
    Hello yogeshdhan78,

    Thank you for your post.

    You have 2 issues here. First, you are calling both an Exit and an Entry order on each first tick of bar, which will result in a doubled position. If you are simply reversing position, all you need to do is call an Entry order in the opposite direction. Remove the exit orders to resolve this.

    The other larger issue, and why you aren't seeing real time trades, is that on the first tick of a bar, the close of that bar will be equal to the open - it's the first tick of the bar so we don't yet know if the bar will be a green or a red bar - it has no direction at that point. You'd need to change those conditions to see real time trades taken. The reason you see historical trades is that on historical data, we only know the OHLC of the bar, so it will be evaluated when the bar closes and any orders would take place on the bar after being triggered as it is essentially running OnBarClose on the historical data of the chart.

    You would need to assess the previous bar and then enter on the first tick of the next bar for that to work.

    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    556 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X