Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

variable calculation

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

    variable calculation

    Good morning. I have a question regarding variable calculations. I'll include a screenshot of the code, but what I'm trying to accomplish is 1) setting a stop loss based on an indicator plot value, 2) subtract that value from my average position price. 3) multiply that result by a user input profit multiplier, and 4) add it to my average position price to determine the price for my exit by limit order. The logic works on the initial order entry, but when the next candle updates and the indicator updates, all the math updates accordingly and moves my limit order down. I have the calculations set under a "marketposition.flat" set, but it seems to be recalculating on the next set while I'm long as well. As always, I appreciate your assistance!

    Click image for larger version

Name:	image.png
Views:	94
Size:	40.5 KB
ID:	1310318

    Click image for larger version

Name:	image.png
Views:	76
Size:	14.3 KB
ID:	1310319

    #2
    Hello medicmiked,

    Add debugging prints to the code to understand the behavior.

    Below is a link to a support article on adding debugging prints to understand behavior.


    Add a print with the bar time to the logic block of the condition assigning the variables values.
    Are you seeing this is printing on bars you are not expecting?
    If so, one line above the condition print all values in the condition with labels for each value and comparison operator.

    Save the output from the output window (right-click Save as) and attach the output text file to your next post.
    I will be happy to assist with analyzing the output.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    127 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X