— Function to calculate the simple moving average function sma(period, data) local sum = 0 for i = 1, period do sum = sum + data[i] end return sum / period end — Define the two moving average periods shortPeriod = 10 longPeriod = 50 — Define the stop loss and take profit levels stopLoss = -5 takeProfit = 10 — Initialize the moving average arrays shortMA = {} longMA = {} — Loop through the data to calculate the moving averages for i = 1, #data do — Calculate the short moving average if i >= shortPeriod then shortMA[i] = sma(shortPeriod, data[i — shortPeriod + 1, i]) end — Calculate the long moving average if i >= longPeriod then longMA[i] = sma(longPeriod, data[i — longPeriod + 1, i]) end — Check if a trade should be opened if shortMA[i] and longMA[i] and shortMA[i] > longMA[i] then — Buy the asset position = «long» — Set the stop loss and take profit levels stopLossPrice = data[i] * (1 + stopLoss / 100) takeProfitPrice = data[i] * (1 + takeProfit / 100) end — Check if the stop loss or take profit levels have been reached if position == «long» then if data[i] <= stopLossPrice then — Sell the asset to exit the trade position = nil end if data[i] >= takeProfitPrice then — Sell the asset to exit the trade position = nil end end end
— Function to calculate the simple moving average
function sma(period, data)
local sum = 0
for i = 1, period do
sum = sum + data[i]
end
return sum / period
end
— Define the two moving average periods
shortPeriod = 10
longPeriod = 50
— Define the stop loss and take profit levels
stopLoss = -5
takeProfit = 10
— Initialize the moving average arrays
shortMA = {}
longMA = {}
— Loop through the data to calculate the moving averages
for i = 1, #data do
— Calculate the short moving average
if i >= shortPeriod then
shortMA[i] = sma(shortPeriod, data[i — shortPeriod + 1, i])
end
— Calculate the long moving average
if i >= longPeriod then
longMA[i] = sma(longPeriod, data[i — longPeriod + 1, i])
end
— Check if a trade should be opened
if shortMA[i] and longMA[i] and shortMA[i] > longMA[i] then
— Buy the asset
position = «long»
— Set the stop loss and take profit levels
stopLossPrice = data[i] * (1 + stopLoss / 100)
takeProfitPrice = data[i] * (1 + takeProfit / 100)
end
— Check if the stop loss or take profit levels have been reached
if position == «long» then
if data[i] <= stopLossPrice then
— Sell the asset to exit the trade
position = nil
end
if data[i] >= takeProfitPrice then
— Sell the asset to exit the trade
position = nil
end
end
end
Если чистая прибыль за 1 квартал составила 268 Млрд. руб, то в кубышке на 1 апреля должно было быть уже больше 6 трлн.(около 6,2 трлн.) Ибо 5,9 выло по итогам прошлого года…
Феликс Осколков, Ну нефть BRENT тогда в минус не уходила. Что-то вроде +15$ за бочку был минимум по ближнему фьючу BRENT в тот момент, когда Лайт делала -37.5$ в 2020 г. А сейчас и нефть Лайт и вов...
было смешно слышать что рост прибыли ожидается за счет расширения офисов и охвата большего колл клиентов, лет 5 назад тоже самое говорили только за счет сокращения излишних офисов и сотрудников и тогд...
dr_xyz, судя по куда-то девающимся юаням, какие-то способы оплаты вполне работоспособны. В конце концов, юань может стоит и 12, и 11 рублей за доллар, а цена товара в юанях для России просто выраст...
Максим Викторов, да, Роснефть себе забирает 90%, а все остальные, включая Башкиров, только 10% при выплате в 25%, лично башкиры забирают 6.25. Роснефть это вполне устраивает, зачем ей у себя самой ...
Понятно, я так же считаю что у меня три квартиры. На самом деле одна в ипотеке, но есть акции + облигации и считаю что долга по ипотеке нету, всё готово к свадьбе сына.
Принцип прост, некое количество пунктов от позиции.
Вот лови:
— Function to calculate the simple moving average function sma(period, data) local sum = 0 for i = 1, period do sum = sum + data[i] end return sum / period end — Define the two moving average periods shortPeriod = 10 longPeriod = 50 — Define the stop loss and take profit levels stopLoss = -5 takeProfit = 10 — Initialize the moving average arrays shortMA = {} longMA = {} — Loop through the data to calculate the moving averages for i = 1, #data do — Calculate the short moving average if i >= shortPeriod then shortMA[i] = sma(shortPeriod, data[i — shortPeriod + 1, i]) end — Calculate the long moving average if i >= longPeriod then longMA[i] = sma(longPeriod, data[i — longPeriod + 1, i]) end — Check if a trade should be opened if shortMA[i] and longMA[i] and shortMA[i] > longMA[i] then — Buy the asset position = «long» — Set the stop loss and take profit levels stopLossPrice = data[i] * (1 + stopLoss / 100) takeProfitPrice = data[i] * (1 + takeProfit / 100) end — Check if the stop loss or take profit levels have been reached if position == «long» then if data[i] <= stopLossPrice then — Sell the asset to exit the trade position = nil end if data[i] >= takeProfitPrice then — Sell the asset to exit the trade position = nil end end end
— Function to calculate the simple moving average
function sma(period, data)
local sum = 0
for i = 1, period do
sum = sum + data[i]
end
return sum / period
end
— Define the two moving average periods
shortPeriod = 10
longPeriod = 50
— Define the stop loss and take profit levels
stopLoss = -5
takeProfit = 10
— Initialize the moving average arrays
shortMA = {}
longMA = {}
— Loop through the data to calculate the moving averages
for i = 1, #data do
— Calculate the short moving average
if i >= shortPeriod then
shortMA[i] = sma(shortPeriod, data[i — shortPeriod + 1, i])
end
— Calculate the long moving average
if i >= longPeriod then
longMA[i] = sma(longPeriod, data[i — longPeriod + 1, i])
end
— Check if a trade should be opened
if shortMA[i] and longMA[i] and shortMA[i] > longMA[i] then
— Buy the asset
position = «long»
— Set the stop loss and take profit levels
stopLossPrice = data[i] * (1 + stopLoss / 100)
takeProfitPrice = data[i] * (1 + takeProfit / 100)
end
— Check if the stop loss or take profit levels have been reached
if position == «long» then
if data[i] <= stopLossPrice then
— Sell the asset to exit the trade
position = nil
end
if data[i] >= takeProfitPrice then
— Sell the asset to exit the trade
position = nil
end
end
end