Третья часть кода:
if (longPyramiding1 == 1 and longPyramiding1[1] == 0 and Order1longtime == time)
strategy.entry("PyramidingLong1TP1", strategy.long, qty = Order1longsize1)
strategy.entry("PyramidingLong1TP2", strategy.long, qty = Order1longsize2)
strategy.entry("PyramidingLong1TP3", strategy.long, qty = Order1longsize3)
strategy.entry("PyramidingLong1TP4", strategy.long, qty = Order1longsize4)
strategy.entry("PyramidingLong1TP5", strategy.long, qty = Order1longsize5)
strategy.entry("PyramidingLong1TP20", strategy.long, qty = Order1longsize20)
strategy.exit("TP1Long1", "PyramidingLong1TP1", qty = Order1longsize1, limit = Order1longtp1, stop = Order1longsl)
strategy.exit("TP2Long1", "PyramidingLong1TP2", qty = Order1longsize2, limit = Order1longtp2, stop = Order1longsl)
strategy.exit("TP3Long1", "PyramidingLong1TP3", qty = Order1longsize3, limit = Order1longtp3, stop = Order1longsl)
strategy.exit("TP4Long1", "PyramidingLong1TP4", qty = Order1longsize4, limit = Order1longtp4, stop = Order1longsl)
strategy.exit("TP5Long1", "PyramidingLong1TP5", qty = Order1longsize5, limit = Order1longtp5, stop = Order1longsl)
strategy.exit("TP20Long1", "PyramidingLong1TP20", qty = Order1longsize20, limit = Order1longtp20, stop = Order1longsl)
if (longPyramiding1 == 1 and longPyramiding2 == 1 and longPyramiding2[1] == 0 and Order1longtime != time and Order2longtime == time)
strategy.entry("PyramidingLong2TP1", strategy.long, qty = Order2longsize1)
strategy.entry("PyramidingLong2TP2", strategy.long, qty = Order2longsize2)
strategy.entry("PyramidingLong2TP3", strategy.long, qty = Order2longsize3)
strategy.entry("PyramidingLong2TP4", strategy.long, qty = Order2longsize4)
strategy.entry("PyramidingLong2TP5", strategy.long, qty = Order2longsize5)
strategy.entry("PyramidingLong2TP20", strategy.long, qty = Order2longsize20)
strategy.exit("TP1Long2", "PyramidingLong2TP1", qty = Order2longsize1, limit = Order2longtp1, stop = Order2longsl)
strategy.exit("TP2Long2", "PyramidingLong2TP2", qty = Order2longsize2, limit = Order2longtp2, stop = Order2longsl)
strategy.exit("TP3Long2", "PyramidingLong2TP3", qty = Order2longsize3, limit = Order2longtp3, stop = Order2longsl)
strategy.exit("TP4Long2", "PyramidingLong2TP4", qty = Order2longsize4, limit = Order2longtp4, stop = Order2longsl)
strategy.exit("TP5Long2", "PyramidingLong2TP5", qty = Order2longsize5, limit = Order2longtp5, stop = Order2longsl)
strategy.exit("TP20Long2", "PyramidingLong2TP20", qty = Order2longsize20, limit = Order2longtp20, stop = Order2longsl)
if (longPyramiding1 == 1 and longPyramiding2 == 1 and longPyramiding3 == 1 and longPyramiding3[1] == 0 and Order1longtime != time and Order2longtime != time and Order3longtime == time)
strategy.entry("PyramidingLong3TP1", strategy.long, qty = Order3longsize1)
strategy.entry("PyramidingLong3TP2", strategy.long, qty = Order3longsize2)
strategy.entry("PyramidingLong3TP3", strategy.long, qty = Order3longsize3)
strategy.entry("PyramidingLong3TP4", strategy.long, qty = Order3longsize4)
strategy.entry("PyramidingLong3TP5", strategy.long, qty = Order3longsize5)
strategy.entry("PyramidingLong3TP20", strategy.long, qty = Order3longsize20)
strategy.exit("TP1Long3", "PyramidingLong3TP1", qty = Order3longsize1, limit = Order3longtp1, stop = Order3longsl)
strategy.exit("TP2Long3", "PyramidingLong3TP2", qty = Order3longsize2, limit = Order3longtp2, stop = Order3longsl)
strategy.exit("TP3Long3", "PyramidingLong3TP3", qty = Order3longsize3, limit = Order3longtp3, stop = Order3longsl)
strategy.exit("TP4Long3", "PyramidingLong3TP4", qty = Order3longsize4, limit = Order3longtp4, stop = Order3longsl)
strategy.exit("TP5Long3", "PyramidingLong3TP5", qty = Order3longsize5, limit = Order3longtp5, stop = Order3longsl)
strategy.exit("TP20Long3", "PyramidingLong3TP20", qty = Order3longsize20, limit = Order3longtp20, stop = Order3longsl)
if (longPyramiding1 == 1 and longPyramiding2 == 1 and longPyramiding3 == 1 and longPyramiding4 == 1 and longPyramiding4[1] == 0 and Order1longtime != time and Order2longtime != time and Order3longtime != time and Order4longtime == time)
strategy.entry("PyramidingLong4TP1", strategy.long, qty = Order4longsize1)
strategy.entry("PyramidingLong4TP2", strategy.long, qty = Order4longsize2)
strategy.entry("PyramidingLong4TP3", strategy.long, qty = Order4longsize3)
strategy.entry("PyramidingLong4TP4", strategy.long, qty = Order4longsize4)
strategy.entry("PyramidingLong4TP5", strategy.long, qty = Order4longsize5)
strategy.entry("PyramidingLong4TP20", strategy.long, qty = Order4longsize20)
strategy.exit("TP1Long4", "PyramidingLong4TP1", qty = Order4longsize1, limit = Order4longtp1, stop = Order4longsl)
strategy.exit("TP2Long4", "PyramidingLong4TP2", qty = Order4longsize2, limit = Order4longtp2, stop = Order4longsl)
strategy.exit("TP3Long4", "PyramidingLong4TP3", qty = Order4longsize3, limit = Order4longtp3, stop = Order4longsl)
strategy.exit("TP4Long4", "PyramidingLong4TP4", qty = Order4longsize4, limit = Order4longtp4, stop = Order4longsl)
strategy.exit("TP5Long4", "PyramidingLong4TP5", qty = Order4longsize5, limit = Order4longtp5, stop = Order4longsl)
strategy.exit("TP20Long4", "PyramidingLong4TP20", qty = Order4longsize20, limit = Order4longtp20, stop = Order4longsl)
if (longPyramiding1 == 1 and longPyramiding2 == 1 and longPyramiding3 == 1 and longPyramiding4 == 1 and longPyramiding5 == 1 and longPyramiding5[1] == 0 and Order1longtime != time and Order2longtime != time and Order3longtime != time and Order4longtime != time and Order5longtime == time)
strategy.entry("PyramidingLong5TP1", strategy.long, qty = Order5longsize1)
strategy.entry("PyramidingLong5TP2", strategy.long, qty = Order5longsize2)
strategy.entry("PyramidingLong5TP3", strategy.long, qty = Order5longsize3)
strategy.entry("PyramidingLong5TP4", strategy.long, qty = Order5longsize4)
strategy.entry("PyramidingLong5TP5", strategy.long, qty = Order5longsize5)
strategy.entry("PyramidingLong5TP20", strategy.long, qty = Order5longsize20)
strategy.exit("TP1Long5", "PyramidingLong5TP1", qty = Order5longsize1, limit = Order5longtp1, stop = Order5longsl)
strategy.exit("TP2Long5", "PyramidingLong5TP2", qty = Order5longsize2, limit = Order5longtp2, stop = Order5longsl)
strategy.exit("TP3Long5", "PyramidingLong5TP3", qty = Order5longsize3, limit = Order5longtp3, stop = Order5longsl)
strategy.exit("TP4Long5", "PyramidingLong5TP4", qty = Order5longsize4, limit = Order5longtp4, stop = Order5longsl)
strategy.exit("TP5Long5", "PyramidingLong5TP5", qty = Order5longsize5, limit = Order5longtp5, stop = Order5longsl)
strategy.exit("TP20Long5", "PyramidingLong5TP20", qty = Order5longsize20, limit = Order5longtp20, stop = Order5longsl)
if (shortPyramiding1 == 1 and shortPyramiding1[1] == 0 and Order1shorttime == time)
strategy.entry("Pyramidingshort1TP1", strategy.short, qty = Order1shortsize1)
strategy.entry("Pyramidingshort1TP2", strategy.short, qty = Order1shortsize2)
strategy.entry("Pyramidingshort1TP3", strategy.short, qty = Order1shortsize3)
strategy.entry("Pyramidingshort1TP4", strategy.short, qty = Order1shortsize4)
strategy.entry("Pyramidingshort1TP5", strategy.short, qty = Order1shortsize5)
strategy.entry("Pyramidingshort1TP20", strategy.short, qty = Order1shortsize20)
strategy.exit("TP1short1", "Pyramidingshort1TP1", qty = Order1shortsize1, limit = Order1shorttp1, stop = Order1shortsl)
strategy.exit("TP2short1", "Pyramidingshort1TP2", qty = Order1shortsize2, limit = Order1shorttp2, stop = Order1shortsl)
strategy.exit("TP3short1", "Pyramidingshort1TP3", qty = Order1shortsize3, limit = Order1shorttp3, stop = Order1shortsl)
strategy.exit("TP4short1", "Pyramidingshort1TP4", qty = Order1shortsize4, limit = Order1shorttp4, stop = Order1shortsl)
strategy.exit("TP5short1", "Pyramidingshort1TP5", qty = Order1shortsize5, limit = Order1shorttp5, stop = Order1shortsl)
strategy.exit("TP20short1", "Pyramidingshort1TP20", qty = Order1shortsize20, limit = Order1shorttp20, stop = Order1shortsl)
if (shortPyramiding1 == 1 and shortPyramiding2 == 1 and shortPyramiding2[1] == 0 and Order1shorttime != time and Order2shorttime == time)
strategy.entry("Pyramidingshort2TP1", strategy.short, qty = Order2shortsize1)
strategy.entry("Pyramidingshort2TP2", strategy.short, qty = Order2shortsize2)
strategy.entry("Pyramidingshort2TP3", strategy.short, qty = Order2shortsize3)
strategy.entry("Pyramidingshort2TP4", strategy.short, qty = Order2shortsize4)
strategy.entry("Pyramidingshort2TP5", strategy.short, qty = Order2shortsize5)
strategy.entry("Pyramidingshort2TP20", strategy.short, qty = Order2shortsize20)
strategy.exit("TP1short2", "Pyramidingshort2TP1", qty = Order2shortsize1, limit = Order2shorttp1, stop = Order2shortsl)
strategy.exit("TP2short2", "Pyramidingshort2TP2", qty = Order2shortsize2, limit = Order2shorttp2, stop = Order2shortsl)
strategy.exit("TP3short2", "Pyramidingshort2TP3", qty = Order2shortsize3, limit = Order2shorttp3, stop = Order2shortsl)
strategy.exit("TP4short2", "Pyramidingshort2TP4", qty = Order2shortsize4, limit = Order2shorttp4, stop = Order2shortsl)
strategy.exit("TP5short2", "Pyramidingshort2TP5", qty = Order2shortsize5, limit = Order2shorttp5, stop = Order2shortsl)
strategy.exit("TP20short2", "Pyramidingshort2TP20", qty = Order2shortsize20, limit = Order2shorttp20, stop = Order2shortsl)
if (shortPyramiding1 == 1 and shortPyramiding2 == 1 and shortPyramiding3 == 1 and shortPyramiding3[1] == 0 and Order1shorttime != time and Order2shorttime != time and Order3shorttime == time)
strategy.entry("Pyramidingshort3TP1", strategy.short, qty = Order3shortsize1)
strategy.entry("Pyramidingshort3TP2", strategy.short, qty = Order3shortsize2)
strategy.entry("Pyramidingshort3TP3", strategy.short, qty = Order3shortsize3)
strategy.entry("Pyramidingshort3TP4", strategy.short, qty = Order3shortsize4)
strategy.entry("Pyramidingshort3TP5", strategy.short, qty = Order3shortsize5)
strategy.entry("Pyramidingshort3TP20", strategy.short, qty = Order3shortsize20)
strategy.exit("TP1short3", "Pyramidingshort3TP1", qty = Order3shortsize1, limit = Order3shorttp1, stop = Order3shortsl)
strategy.exit("TP2short3", "Pyramidingshort3TP2", qty = Order3shortsize2, limit = Order3shorttp2, stop = Order3shortsl)
strategy.exit("TP3short3", "Pyramidingshort3TP3", qty = Order3shortsize3, limit = Order3shorttp3, stop = Order3shortsl)
strategy.exit("TP4short3", "Pyramidingshort3TP4", qty = Order3shortsize4, limit = Order3shorttp4, stop = Order3shortsl)
strategy.exit("TP5short3", "Pyramidingshort3TP5", qty = Order3shortsize5, limit = Order3shorttp5, stop = Order3shortsl)
strategy.exit("TP20short3", "Pyramidingshort3TP20", qty = Order3shortsize20, limit = Order3shorttp20, stop = Order3shortsl)
if (shortPyramiding1 == 1 and shortPyramiding2 == 1 and shortPyramiding3 == 1 and shortPyramiding4 == 1 and shortPyramiding4[1] == 0 and Order1shorttime != time and Order2shorttime != time and Order3shorttime != time and Order4shorttime == time)
strategy.entry("Pyramidingshort4TP1", strategy.short, qty = Order4shortsize1)
strategy.entry("Pyramidingshort4TP2", strategy.short, qty = Order4shortsize2)
strategy.entry("Pyramidingshort4TP3", strategy.short, qty = Order4shortsize3)
strategy.entry("Pyramidingshort4TP4", strategy.short, qty = Order4shortsize4)
strategy.entry("Pyramidingshort4TP5", strategy.short, qty = Order4shortsize5)
strategy.entry("Pyramidingshort4TP20", strategy.short, qty = Order4shortsize20)
strategy.exit("TP1short4", "Pyramidingshort4TP1", qty = Order4shortsize1, limit = Order4shorttp1, stop = Order4shortsl)
strategy.exit("TP2short4", "Pyramidingshort4TP2", qty = Order4shortsize2, limit = Order4shorttp2, stop = Order4shortsl)
strategy.exit("TP3short4", "Pyramidingshort4TP3", qty = Order4shortsize3, limit = Order4shorttp3, stop = Order4shortsl)
strategy.exit("TP4short4", "Pyramidingshort4TP4", qty = Order4shortsize4, limit = Order4shorttp4, stop = Order4shortsl)
strategy.exit("TP5short4", "Pyramidingshort4TP5", qty = Order4shortsize5, limit = Order4shorttp5, stop = Order4shortsl)
strategy.exit("TP20short4", "Pyramidingshort4TP20", qty = Order4shortsize20, limit = Order4shorttp20, stop = Order4shortsl)
if (shortPyramiding1 == 1 and shortPyramiding2 == 1 and shortPyramiding3 == 1 and shortPyramiding4 == 1 and shortPyramiding5 == 1 and shortPyramiding5[1] == 0 and Order1shorttime != time and Order2shorttime != time and Order3shorttime != time and Order4shorttime != time and Order5shorttime == time)
strategy.entry("Pyramidingshort5TP1", strategy.short, qty = Order5shortsize1)
strategy.entry("Pyramidingshort5TP2", strategy.short, qty = Order5shortsize2)
strategy.entry("Pyramidingshort5TP3", strategy.short, qty = Order5shortsize3)
strategy.entry("Pyramidingshort5TP4", strategy.short, qty = Order5shortsize4)
strategy.entry("Pyramidingshort5TP5", strategy.short, qty = Order5shortsize5)
strategy.entry("Pyramidingshort5TP20", strategy.short, qty = Order5shortsize20)
strategy.exit("TP1short5", "Pyramidingshort5TP1", qty = Order5shortsize1, limit = Order5shorttp1, stop = Order5shortsl)
strategy.exit("TP2short5", "Pyramidingshort5TP2", qty = Order5shortsize2, limit = Order5shorttp2, stop = Order5shortsl)
strategy.exit("TP3short5", "Pyramidingshort5TP3", qty = Order5shortsize3, limit = Order5shorttp3, stop = Order5shortsl)
strategy.exit("TP4short5", "Pyramidingshort5TP4", qty = Order5shortsize4, limit = Order5shorttp4, stop = Order5shortsl)
strategy.exit("TP5short5", "Pyramidingshort5TP5", qty = Order5shortsize5, limit = Order5shorttp5, stop = Order5shortsl)
strategy.exit("TP20short5", "Pyramidingshort5TP20", qty = Order5shortsize20, limit = Order5shorttp20, stop = Order5shortsl)