Скрипт для расчета кол-ва лотов? - страница 2

 

А может кто-то в индикаторе от Prival сможет

ЗАДАТЬ ЦЕНУ ОДНОГО ПУНКТА ПРИ ОДНОМ ЛОТЕ

ЗАДАТЬ ЦЕНУ ОДНОГО ПУНКТА ПРИ ЗАДАННОМ РИСКЕ И ПОЛУЧЕННОМ КОЛ-ВЕ ЛОТОВ

Извините, что большими буквами. Привык. В коде почти не разбираюсь.

sp = (MarketInfo(Symbol(),MODE_SPREAD)*MarketInfo(Symbol(),MODE_POINT))/Point;//NormalizeDouble((Ask-Bid)/Point/p, 1);//ЭТО ОТ КИМА
      stop_level=MarketInfo( Symbol(), MODE_STOPLEVEL);
      
   ObjectCreate("Spread",OBJ_LABEL,0,0,0);
   ObjectSet("Spread",OBJPROP_CORNER,1);
   ObjectSet("Spread",OBJPROP_XDISTANCE,1);
   ObjectSet("Spread",OBJPROP_YDISTANCE,52);//130);//0);
   ObjectSetText("Spread","Spread  "+DoubleToStr(sp, 2)+".",9,"Impact",Blue);   
   
   ObjectCreate("Stop_level",OBJ_LABEL,0,0,0);
   ObjectSet("Stop_level",OBJPROP_CORNER,1);
   ObjectSet("Stop_level",OBJPROP_XDISTANCE,1);
   ObjectSet("Stop_level",OBJPROP_YDISTANCE,65);//160);//0);
   ObjectSetText("Stop_level","Stop_level  "+DoubleToStr(stop_level, 0)+".",9,"Impact",Blue);   
    
здесь где-то ...
   
 
A Sample: Lot size computing:

double avd.OperationVolume    ;

double avd.VARLimit  = 200.00 ;
int    avi.VARPoints = 50     ;

//<init>
int    init
 (//<0>
){//<1>
 
avd.OperationVolume = amd.OperationVolume ( Symbol () , avd.VARLimit , avi.VARPoints ) ;

}//</init> 

//<amd.OperationVolume>
double amd.OperationVolume
 (//<3>
       string aas.Symbol    ,
       double aad.VARLimit  ,
       int    aai.VARPoints
){//<31>

double ald.VolumeStep      = MarketInfo ( aas.Symbol , MODE_LOTSTEP        )                        ;
double ald.MinimalVolume   = MarketInfo ( aas.Symbol , MODE_MINLOT         )                        ;
double ald.NominalLot      = MarketInfo ( aas.Symbol , MODE_LOTSIZE        )                        ;
double ald.NominalMargin   = MarketInfo ( aas.Symbol , MODE_MARGINREQUIRED )                        ;
double ald.NominalTick     = MarketInfo ( aas.Symbol , MODE_TICKVALUE      )                        ;
double ald.QuoteTick       = MarketInfo ( aas.Symbol , MODE_TICKSIZE       )                        ;
double ald.QuotePoint      = MarketInfo ( aas.Symbol , MODE_POINT          )                        ;

double ald.MinimalMargin   = ald.NominalMargin       * ald.MinimalVolume                            ;
double ald.MinimalTick     = ald.NominalTick         * ald.MinimalVolume                            ;
double ald.MinimalPoint    = ald.MinimalTick         * ald.QuotePoint    / ald.QuoteTick            ;
int    ali.PositionPoints  = MathRound               ( ald.MinimalMargin / ald.MinimalPoint )       ;

double ald.VARPositions    = aai.VARPoints * 1.0     / ali.PositionPoints                           ;
double ald.MarginLimit     = avd.VARLimit            / ald.VARPositions                             ;
double ald.VolumeLimit     = ald.MarginLimit         / ald.NominalMargin                            ;
 
double ald.OperationVolume = 0                                                                      ;

if   ( ald.VolumeLimit    >= ald.MinimalVolume )
     { int ali.Steps       = MathFloor ( ( ald.VolumeLimit - ald.MinimalVolume ) / ald.VolumeStep ) ;
       ald.OperationVolume = ald.MinimalVolume + ald.VolumeStep * ali.Steps                         ; }

string als.LotMeasure      , als.BaseCurrency                                                       ;

if   ( AccountLeverage () != NormalizeDouble ( ald.NominalLot / ald.NominalMargin , 1 ) )
     { als.BaseCurrency    = StringSubstr    ( aas.Symbol , 0 , 3 )                                 ;
       als.LotMeasure      = als.BaseCurrency                                                       ; }
else   als.LotMeasure      = AccountCurrency ()                                                     ;

Alert  ( " "                                                                                      ) ;
Alert  ( "ald.OperationVolume = " , ald.OperationVolume , " " , "lots"                            ) ;
Alert  ( "Output :"                                                                               ) ;
Alert  ( " "                                                                                      ) ;
Alert  ( "ald.MinimalVolume   = " , ald.MinimalVolume   , " " , "lots"                            ) ;
Alert  ( "ald.VolumeStep      = " , ald.VolumeStep      , " " , "lots"                            ) ;
Alert  ( "ald.VolumeLimit     = " , ald.VolumeLimit     , " " , "lots"                            ) ;
Alert  ( "ald.MarginLimit     = " , ald.MarginLimit     , " " , AccountCurrency ()                ) ;
Alert  ( "aad.VARLimit        = " , aad.VARLimit        , " " , AccountCurrency ()                ) ;
Alert  ( "ald.VARPositions    = " , ald.VARPositions    , " " , "positions"                       ) ;
Alert  ( "aai.VARPoints       = " , aai.VARPoints       , " " , "points"                          ) ;
Alert  ( "ali.PositionPoints  = " , ali.PositionPoints  , " " , "points"                          ) ;
Alert  ( "ald.MinimalPoint    = " , ald.MinimalPoint    , " " , AccountCurrency ()                ) ;
Alert  ( "ald.MinimalMargin   = " , ald.MinimalMargin   , " " , AccountCurrency ()                ) ;
Alert  ( "ald.NominalMargin   = " , ald.NominalMargin   , " " , AccountCurrency ()                ) ;
Alert  ( "ald.NominalLot      = " , ald.NominalLot      , " " , als.LotMeasure                    ) ;
Alert  ( "Processing :"                                                                           ) ;
Alert  ( " "                                                                                      ) ;
Alert  ( "aai.VARPoints       = " , aai.VARPoints       , " " , "points"                          ) ;
Alert  ( "aad.VARLimit        = " , aad.VARLimit        , " " , AccountCurrency ()                ) ;
Alert  ( "aas.Symbol          = " , aas.Symbol                                                    ) ;
Alert  ( "Input :"                                                                                ) ;
Alert  ( " "                                                                                      ) ;
Alert  ( "AccountLeverage ()  = " , AccountLeverage ()                                            ) ;
Alert  ( "AccountCurrency ()  = " , AccountCurrency ()                                            ) ;
 
return ( ald.OperationVolume )                                                                      ;

}//</amd.OperationVolume>
 



Lot size computing: Пояснения
Понятие "Position" в данном случае обозначает маржинальную позицию, то есть размер залога.
Переменная "ali.PositionPoints" обозначает размер маржинальной позиции в пунктах.
 
A Sample: Value to point conversion

int init ()                                                                                      //<   1>
{                                                                                                //<   2>
string acs.Operation [] = { "Buy" , "Sell"                                                   } ; //<   3>
                                                                                                 //<   4>
double avd.QuotePoint   = MarketInfo  ( Symbol ()        , MODE_POINT       )                  ; //<   5>
double avd.QuoteTick    = MarketInfo  ( Symbol ()        , MODE_TICKSIZE    )                  ; //<   6>
double avd.NominalTick  = MarketInfo  ( Symbol ()        , MODE_TICKVALUE   )                  ; //<   7>
double ald.NominalPoint = avd.NominalTick                * avd.QuotePoint   / avd.QuoteTick    ; //<   8>
                                                                                                 //<   9>
Alert ( ""                                                                                   ) ; //<  10>
Alert ( "avd.QuotePoint:   "          , DoubleToStr      ( avd.QuotePoint   , Digits       ) ) ; //<  11>
Alert ( "avd.QuoteTick:    "          , DoubleToStr      ( avd.QuoteTick    , Digits       ) ) ; //<  12>
Alert ( "avd.NominalTick:  "          , DoubleToStr      ( avd.NominalTick  , 2            ) ) ; //<  13>
Alert ( "ald.NominalPoint: "          , DoubleToStr      ( ald.NominalPoint , 2            ) ) ; //<  14>
                                                                                                 //<  15>
if ( OrdersTotal ()   > 0             )                                                          //<  16>
   { int   i , N ; N  = OrdersTotal  () - 1                                                    ; //<  17>
     for ( i = N ; i >= 0 ; i --      )                                                          //<  18>
       {   OrderSelect    ( i         , SELECT_BY_POS    , MODE_TRADES      )                  ; //<  19>
                                                                                                 //<  20>
           double ald.OrderProfit     = OrderProfit      ()                                    ; //<  21>
           double ald.ContractSize    = OrderLots        ()                                    ; //<  22>
           double ald.OrderPoint      = ald.NominalPoint * ald.ContractSize                    ; //<  23>
           int    ali.OrderProfit     = MathRound        ( ald.OrderProfit  / ald.OrderPoint ) ; //<  24>
                                                                                                 //<  25>
           Alert ( ""                                                                        ) ; //<  26>
                                                                                                 //<  27>
           Alert ( "Profit, points: " , ali.OrderProfit                                      ) ; //<  28>
                                                                                                 //<  29>
           Alert ( "Profit, "         , AccountCurrency  ()                                  ,   //<  30>
                                " : " , DoubleToStr      ( ald.OrderProfit  , 2            ) ) ; //<  31>
                                                                                                 //<  32>
           Alert ( "Order Point, "    , AccountCurrency  ()                                  ,   //<  33>
                                " : " , DoubleToStr      ( ald.OrderPoint   , 2            ) ) ; //<  34>
                                                                                                 //<  35>
           Alert ( "Size, lots:     " , DoubleToStr      ( ald.ContractSize , 2            ) ) ; //<  36>
           Alert ( "Type:           " , acs.Operation    [ OrderType     () ]                ) ; //<  37>
           Alert ( "Ticket:        #" , OrderTicket      ()                                  ) ; //<  38>
                                                                                                 //<  39>
       } // for                                                                                  //<  40>
   } // if                                                                                       //<  41>
}                                                                                                //<  42>
 
 
OZ0 >>:

А может кто-то в индикаторе от Prival сможет

ЗАДАТЬ ЦЕНУ ОДНОГО ПУНКТА ПРИ ОДНОМ ЛОТЕ

ЗАДАТЬ ЦЕНУ ОДНОГО ПУНКТА ПРИ ЗАДАННОМ РИСКЕ И ПОЛУЧЕННОМ КОЛ-ВЕ ЛОТОВ

Извините, что большими буквами. Привык. В коде почти не разбираюсь.

Нужно исправить то что ниже      

Lot_price1=MarketInfo( Symbol(),MODE_MINLOT);//А ЗДЕСЬ ВМЕСТО ЭТОЙ СТРОЧКИ НУЖНО ЗАДАТЬ ЦЕНУ ОДНОГО ПУНКТА ПРИ ОДНОМ ЛОТЕ
Punkt_price1=MarketInfo( Symbol(),MODE_POINT);//А ЗДЕСЬ НУЖНО ЗАДАТЬ ЦЕНУ ОДНОГО ПУНКТА ПРИ ЗАДАННОМ РИСКЕ И ПОЛУЧЕННОМ КОЛ-ВЕ ЛОТОВ



Спасибо Ais, но для меня код китайская грамота, а люды просють ... 
 
Цена 1 пункта для стандартного лота:
 
double ad.QuotePoint   = MarketInfo ( Symbol () , MODE_POINT     )      ;
double ad.QuoteTick    = MarketInfo ( Symbol () , MODE_TICKSIZE  )      ;
double ad.NominalTick  = MarketInfo ( Symbol () , MODE_TICKVALUE )      ;

double ad.NominalPoint = ad.NominalTick  * ad.QuotePoint / ad.QuoteTick ; // Цена 1 пункта для стандартного лота
Цена 1 пункта для ордера известного размера "ad.OrderSize":

double ad.OrderPoint   = ad.NominalPoint * ad.OrderSize                 ;
 

Большое спасибо Айрат ...

Вы не брат Марата Сафина?

Очень люблю теннис. Желаю соотечественнику удачи!

Причина обращения: