Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy stops after one trade

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

  • fredfred123
    replied
    you got it Thanks a lot !

    Leave a comment:


  • sledge
    replied
    I'm going to guess that entryOrder is no longer null after you assign it in the OnExecutionUpdate - hence blocking further trades.

    Leave a comment:


  • fredfred123
    started a topic strategy stops after one trade

    strategy stops after one trade

    Can anybody help with this script please?

    It makes a trade once and then doesn't make any more when the conditions are met.
    needs re-enabling to makes another trade, then makes one trade and so forth.
    Script is as follows: Compiles OK


    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Historical)
    {
    SetProfitTarget(CalculationMode.Ticks, 60);
    SetStopLoss(CalculationMode.Ticks, 60);


    }
    else if (State == State.DataLoaded)
    {

    QuantumDynamicPricePivots1 = QuantumDynamicPricePivots(Close, 10);
    VolumeOscillator1 = VolumeOscillator(Close, 3, 50);
    }
    }


    protected override void OnBarUpdate()
    {
    if (CurrentBar < 5)
    return;

    if(State == State.Historical) return;

    if ((entryOrder == null && Close[0] > 0)
    && (VolumeOscillator1[0] > 0)
    &&(QuantumDynamicPricePivots1.MarketAnalyzerPlo t[0] == -1))


    EnterLong("myEntryOrder");



    if (BarsSinceEntryExecution() >3)
    {
    ExitLong();


    }



    }
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
    // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
    // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not gauranteed to be complete if it is referenced immediately after submitting
    if (execution.Order.Name == "myEntryOrder" && execution.Order.OrderState == OrderState.Filled)
    entryOrder = execution.Order;

    if (entryOrder != null && entryOrder == execution.Order)
    Print(execution.ToString());
    }





    }
    }

    Many thanks

Latest Posts

Collapse

Topics Statistics Last Post
Started by aligator, Today, 02:38 PM
0 responses
5 views
0 likes
Last Post aligator  
Started by Stett0002, Yesterday, 11:55 PM
1 response
11 views
0 likes
Last Post NinjaTrader_ShawnB  
Started by KasLB, Today, 05:12 AM
2 responses
17 views
1 like
Last Post KasLB
by KasLB
 
Started by LeitoGTR, Yesterday, 06:41 PM
1 response
11 views
0 likes
Last Post NinjaTrader_ShawnB  
Started by Prisalice, Today, 07:07 AM
1 response
10 views
0 likes
Last Post NT-Roland  
Working...
X