SHARE
TWEET

Untitled

a guest Jun 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Called by the framework whenever someone closes a price position
  2. private void Positions_Closed(PositionClosedEventArgs args)
  3.         {
  4.         //Flag so we don't place any more orders or anything until this method completes
  5.         _wasClosingEventFired = true;
  6.  
  7.         //other stuff this method does
  8.  
  9.         //Signal that this method is over with
  10.         _wasClosingEventFired = false;
  11.         }
  12.  
  13. //This method is called by the framework every time a new price comes in
  14. //This is unpredictable and could be 1ms from "now", 2 seconds from "now", etc.
  15. protected override void OnTick()
  16.         {
  17.             AnalyzeMarket();
  18.         }
  19.  
  20. private void AnalyzeMarket()
  21.     {
  22.         //Does a few preliminary logging and other set ups
  23.  
  24.         if (!_wasClosingEventFired)
  25.             {
  26.             //Does the brunt of the work
  27.             //This is the code we want to make sure doesn't
  28.             //run when a closing event happens. If that means
  29.             //we have to wait a few "ticks", that's fine.
  30.         }
  31.  
  32.         //Clean up stuff
  33.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top