Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't a brother just pass a variable?

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

    Can't a brother just pass a variable?

    Ok, this could get super complicated quick so I'll try to keep it simple and let you ask question if you don't follow me.
    Task: Store "AllTrades" - Quantity. Then pass the data to my "private double _sizeDoubler" so I can increase the my lot size if the last trade was a loss.
    I have wrote many different configurations. I'll leave what I feel should definitely be working below:

    The following code is written below "OnExecutionUpdate".


    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    private void MartingaleManagment(Order order)
    {
    double _sizeDoubler = 0;
    var lossInPips = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitPips;
    var lossInPoints = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitPoints;
    var sizeLastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].Quantity;

    if (lossInPips <= 0 || lossInPoints < 0)
    {
    _sizeDoubler = (int) lastTradeQty;

    if (MyMarketType == MarketType.Forex)
    {
    _posSize = _(int) _sizeDoubler * 8;
    }

    else if (MyMarketType == MarketType.Other)

    _posSize = (int) _sizeDoubler * 8;

    }
    else
    {
    _posSize = InitialLotSize;
    }
    }


    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    I have tries a lot of variations of this. Getting AllTrades info under "OnBarUpdate". Declairing "_sizeDoubler" as a private and public Double at the top with the other varables. What am I doing wrong here? The Logic for finding if the last trade was a loss works. I just can't get the trade size data from the last trade. Or last losing trade...

    Here is another attempt:

    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    (In OnBarUpdate)

    if (SystemPerformance.AllTrades.Count > 0)
    {
    // Check to make sure there is at least one trade in the collection
    Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];

    lastTradeQty = lastTrade.Quantity;
    Print("The last trade's quantity " + (lastTradeQty));
    }


    (In OnExecutionUpdate)
    private void MartingaleManagment(Order order)
    {
    var lossInPips = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitPips;
    var lossInPoints = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitPoints;

    if (lossInPips <= 0 || lossInPoints < 0)

    if (MyMarketType == MarketType.Forex)
    {
    _posSize = (int) lastTradeQty* 8;
    }

    else if (MyMarketType == MarketType.Other)

    _posSize = (int) lastTradeQty * 8;

    }
    else
    {
    _posSize = InitialLotSize;
    }
    }

    //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Any thoughts?


    #2
    Well never mind, I figured it out. It seems I need to get tired pushing for too long, freak out and write to you guys. Then grab a coffee and find that the answer comes to me! Thanks anyway!

    Comment


      #3
      Originally posted by White Fork View Post
      Well never mind, I figured it out. It seems I need to get tired pushing for too long, freak out and write to you guys. Then grab a coffee and find that the answer comes to me! Thanks anyway!
      I think it taking too long for you!

      cps test

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 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