41 lines
1.5 KiB
MQL5
41 lines
1.5 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| SampleStrategyState .mqh |
| |||
//| Copyright 2025, MetaQuotes Ltd. |
| |||
//| https://www.mql5.com |
| |||
//+------------------------------------------------------------------+
| |||
#property copyright "Copyright 2025, MetaQuotes Ltd."
| |||
#property link "https://www.mql5.com"
| |||
#property version "1.00"
| |||
//+------------------------------------------------------------------+
| |||
//| SampleStrategyState.mqh |
| |||
//+------------------------------------------------------------------+
| |||
#include "IState.mqh"
| |||
| |||
class SampleStrategyState : public IState
| |||
{
| |||
private:
| |||
int m_lastSignalDirection;
| |||
int m_tradesThisSession;
| |||
| |||
public:
| |||
SampleStrategyState() : m_lastSignalDirection(0), m_tradesThisSession(0) {}
| |||
| |||
// Getters/setters for live use (omitted for brevity)
| |||
| |||
virtual JSON::Object* Save() override
| |||
{
| |||
JSON::Object* obj = new JSON::Object();
| |||
obj.setProperty("lastSignalDirection", m_lastSignalDirection);
| |||
obj.setProperty("tradesThisSession", m_tradesThisSession);
| |||
return obj;
| |||
}
| |||
| |||
virtual bool Load(const JSON::Object* json) override
| |||
{
| |||
if(json == NULL) return false;
| |||
m_lastSignalDirection = (int)json.getNumber("lastSignalDirection");
| |||
m_tradesThisSession = (int)json.getNumber("tradesThisSession");
| |||
return true;
| |||
}
| |||
};
| |||
//+------------------------------------------------------------------+
|