• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 atman, Today, 12:37 AM
      0 responses
      2 views
      0 likes
      Last Post atman
      by atman
       
      Started by random9570, Yesterday, 09:01 PM
      1 response
      13 views
      0 likes
      Last Post Fulcanelli  
      Started by natngk, Yesterday, 08:28 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by Borsz, 05-27-2020, 10:37 AM
      2 responses
      24 views
      0 likes
      Last Post aligator  
      Started by Tagliareni, Yesterday, 08:10 PM
      0 responses
      8 views
      0 likes
      Last Post Tagliareni  
      Working...
      X