Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategies interdependencies

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

    strategies interdependencies

    Hello,

    I want to ask please if there are interdependencies that might cause issues when running 2 scripts on same instrument, eg one script in a range chart and another script in a tickchart. Both scripts in onbarupdate there is the check if flat or long or short. Can there be some issue with stops or with conditions because of the other script maybe?

    I use different ordernames:
    entryOrderSr1a=EnterShort(4,1, "rS1a"); // strategy running in a range-chart
    entryOrderTSr1a=EnterShort(4,1, "TrS1a"); // strategy running in a tick-chart

    It seems there is an issue with my lines I´m working with (for catching pivots, moving stops...) that I remote with my customized buttons. When I moved the line in one chart it doesnt work in the other chart anymore. I have in onbarupdate
    if(shortlinedraw==false)
    {
    if(storeshort>0 && (Closes[4][0]>Lows[4][0]-1*TickSize || Closes[4][0]<Highs[4][0]+1*TickSize) && shortlinedraw==false)
    {TxShortLine = Draw.HorizontalLine(this, "TxShortLine", true, Highs[4][0]+2*TickSize, Brushes.DeepPink, DashStyleHelper.Dash,2);shortlinedraw=true;TxShort Line.IsLocked=false;}
    }
    if(shortlinedraw==true)
    {
    if (DrawObjects["TxShortLine"] != null && DrawObjects["TxShortLine"] is DrawingTools.HorizontalLine)
    {
    shortlinePrice = Instrument.MasterInstrument.RoundToTickSize(TxShor tLine.StartAnchor.Price);
    shortlinevalue = shortlinePrice;
    }}​

    I could build this from the helpguide. Do I have to add something so that when I move the line it does not have impact on the line in the other script?


    Thank you!
    Tony​
    Last edited by tonynt; 08-24-2024, 09:26 AM. Reason: translation error

    #2
    Hello tonynt,

    Strategies do not know what other strategies are doing so they can submit conflicting actions and become out of sync. If you need to run two strategies on the same instrument it is suggested to combine the logic into one strategy and just run that.

    Regarding your lines I couldn't say what may be happening there, have you tried to debug the code using prints? A script can only manage its own lines so if you are drawing from two scripts you would need to make sure to use unique tag names for each scripts lines.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    48 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X